class Solution {
public:
    string clearDigits(string s) {
        string ret;
        for (auto c : s)
        {
            if (isdigit(c) && ret.size() > 0)
                ret.pop_back();
            else
                ret.push_back(c);
        }
        return ret;
    }
};